package com.lagou.serializer;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.io.IOException;

/**
 * @author Kirito
 * @description:
 * @date 2020/05/22
 */
public class JSONSerializer implements Serializer {
    public byte[] serialize(Object object) throws IOException {
        return JSONObject.toJSONBytes(object);
    }

    public <T> T deSerialize(Class<T> clazz, byte[] bytes) throws IOException {
        return JSON.parseObject(bytes, clazz);
    }
}
